<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Shop;

class CreateShopsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create( Shop::TABLE, function (Blueprint $table) {
            $table->integer('user_id')->unsigned();//所属ID
            $table->integer('shop_sn');//店铺编码
            $table->string('flag',32);//店铺标识
            $table->string('name', 255);//店铺名称
            $table->string('type', 255);//店铺类型【免费类型,收费类型】
            $table->integer('level')->default(1);//店铺等级
            $table->integer('created_id');//创建人ID
            $table->integer('sell_num')->default(0);//销售商品总数
            $table->integer('integral')->default(0);//积分
            $table->decimal('asset', 15, 6)->default(0);//资产
            $table->decimal('frozen_asset', 15, 6)->default(0);//冻结资产
            $table->decimal('expense_asset', 15, 6)->default(0);//消费资产
            $table->boolean('available')->default(true);
            $table->string('status')->default(true);
            $table->timestamp('forbid_at')->nullable();
            $table->softDeletes();
            $table->timestamps();
            $table->primary(['flag', 'name']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(Shop::TABLE);
    }
